<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>FLASHDEMO</title>
        <script src="https://cdn.jsdelivr.net/npm/@ruffle-rs/ruffle@0.1.0-nightly.2023.9.3/ruffle.min.js"></script>
    </head>
    <body>
        <!-- <div>
            <div id="gameContent" class="g-inner" datapath="../../zmTool/bin-debug/zmTool.swf"></div>
            <embed  style="width:940px;height:590px;" src="zm5.swf">
            <embed id="embed" style="width:1100px;height:700px;" src="zmTool.swf">
        </div>
        -->
        <div id="container"></div>
        <div id='dragDiv' style='position:absolute;left:1110px;top:10px;'>
            <div style='height:700px;width:300px;background-color:#444444;color:#ffffff;'>
                把swf文件拖到这里面
                <br>
                <div id='btnDiv'>
                </div>
            </div>
        </div>
        <div id="btns" style='position:absolute;left:10px;top:650px;'>
            
        </div>
        <script>
            //flash收藏https://flash.zczc.cz/
            var player;
            window.RufflePlayer = window.RufflePlayer || {};
            window.addEventListener("load", (event) => {
                const ruffle = window.RufflePlayer.newest();
                player = ruffle.createPlayer();
                const container = document.getElementById("container");
                container.appendChild(player);
                player.style.width = "1100px";
                player.style.height = "600px";
                //player.load("zm5.swf");
            });
            var embed=document.getElementById('embed');
            var dragDiv=document.getElementById('dragDiv');
            var btnDiv=document.getElementById('btnDiv');
            var files;
            dragDiv.ondragover = function (e) {
                e.preventDefault();
            }
            dragDiv.ondrop = function (e) {
                console.log(e.dataTransfer.files);
                e.preventDefault();
                files=e.dataTransfer.files;
                for(var i=0;i<files.length;i++){
                    var file=files[i];
                    var btn=document.createElement('input');
                    btn.addEventListener('click',onClick);
                    btn.type='button';
                    //btn.style='background-color: #4CAF50;border: none;color: white;';
                    btn.file=file;
                    btn.value=file.name.split('.')[0]
                    btnDiv.appendChild(btn);
                }
                console.log(btnDiv.children)
            }
            function onClick(e){
                console.log(e.target.file);
                var file = e.target.file;  
                var reader = new FileReader();  
                reader.onload = function() {  
                    // embed.src=this.result;
                    player.load(this.result);
                }
                reader.readAsDataURL(file);
            }
            var btns=document.getElementById('btns');
            var names=['小破孩连连看','大学自习曲','东北都是活雷锋','黄金矿工','小小特警','QQ连连看','功夫祖玛','对对碰','森林冰火人','迷宫'];
            var urls=['https://flash-swf-sh-1253151332.file.myqcloud.com/1872cab9fb25777e15ad6fbb0bd01be2788d2a072ac205ce8dc4c07411635412.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/c472b7c278fb8aa1d8fe95c8c2ab4660f83bc00e7977dd7861906e447eca7cce.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/dc201a7e8843d32cb4cba4dbaa845624cd3f171e157060d2563d97b1140b2d10.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/0c3d410285d69a36022f652b0c28e5c5f6d56b6112d6c77500c9b09387122eeb.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/7d831cadf2f6f72925e4bcee571c0d3a7f337ae52363825637f0a20b87111e25.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/8d284037962fe18d17e197ceb5b47f5a9ab29a8304c30a960e83c4eca8b2f767.swf'
            ,'https://b2.zczc.cz/file/flash-swf/76f0f3a913e4f5765f07035549235f8dc6187535d3ce9cee30642fb04e27624e.swf'
            ,'https://b2.zczc.cz/file/flash-swf/7f2db195b4389649cc2a03f25f77f26fdfad7072aaec2eac84803bc0bfd4523c.swf'
            ,'https://flash-swf-sh-1253151332.file.myqcloud.com/e46eda9b1004c280aa1ce7e8396d1513d2a98376fbc4f82c2ace5df73fed758e.swf'
            ,'https://b2.zczc.cz/file/flash-swf/adaf9bcb91a9374915f0a7c957640fa7868ad00fc78bbfc3c1fbca0a2a602930.swf'
        ];
            for(let i=0;i<names.length;i++){
                var btn=document.createElement('button');
                btn.innerHTML=names[i];
                btn.addEventListener('click',loadGame)
                btn.name=urls[i];
                document.body.appendChild(btn);
            }
            function loadGame(e){
                console.log(e.target.name);
                player.load(e.target.name);
            }
        </script>
    </body>

</html>